$(function () {
    layui.use(['form', 'layedit', 'laydate'], function() {
        var form = layui.form
            , layer = layui.layer
            , layedit = layui.layedit
            , laydate = layui.laydate;
    });
    let data = dataGroup.list;
    let html='';
    for (let i = 0;i<data.length;i++){
        html+='<div style="height:80px;padding-left: 400px ">\n' +
            '    <div style="float: left;line-height: 38px">'+data[i].personnelName+'</div>\n' +
            '    <div style="float: left">\n' +
            '        <form class="layui-form" action="">\n' +
            '            <div class="layui-form-item" pane="">\n' +
            '                <label class="layui-form-label">到岗状态</label>\n' +
            '                <div class="layui-input-block">\n' +
            '                    <input name="sex'+i+'" title="已到" type="radio" checked="" value="已到" lay-filter="bbb'+i+'">\n' +
            '                    <input name="sex'+i+'" title="请假" type="radio" value="请假" lay-filter="bbb'+i+'">\n' +
            '                    <input name="sex'+i+'" title="旷课" type="radio" value="旷课" lay-filter="bbb'+i+'">\n' +
            '                    <input name="sex'+i+'" title="迟到" type="radio" value="迟到" lay-filter="aaa'+i+'">\n' +
            '                </div>\n' +
            '            </div>\n' +
            '        </form>\n' +
            '    </div>\n' +
            '    <div style="float: left" id="chidao'+i+'">\n' +
            '    </div>\n' +
            '</div>'
    }
    $("#dianDaoManage").html(html);
})
function submitDianDao() {
    let list = dataGroup.list;
    let data1=[];
    let myDate = new Date();
    let seperator1 = "-";
    var year = myDate.getFullYear();
    let month = myDate.getMonth() + 1;
    let strDate = myDate.getDate();
    if (month >= 1 && month <= 9) {
        month = "0" + month;
    }
    if (strDate >= 0 && strDate <= 9) {
        strDate = "0" + strDate;
    }
    let currentdate = year + seperator1 + month + seperator1 + strDate;
    for (let i=0;i<list.length;i++){
        let data = {
            personnelName:list[i].personnelName,
            dianDaoState:$("input[name='sex"+i+"']:checked").val(),
            chidaoTime:$("#date"+i+"").val(),
            diandaoTime:currentdate,
        }
        data1.push(data);
    }
    console.log(data1);
    let result = myAjax("/dianDao/dianDaoAdd",data1,"post");
    if (result.result==1){
        alert("增加成功");
    }else {
        alert("增加失败")
    }

}
layui.use(['form', 'layedit', 'laydate'], function(){
    var form = layui.form
        ,layer = layui.layer
        ,layedit = layui.layedit
        ,laydate = layui.laydate;
    for (let i=0;i<dataGroup.list.length;i++){
        layui.form.on('radio(aaa'+i+')', function(){
            let html ='<form class="layui-form" action="">\n' +
                '            <div class="layui-inline">\n' +
                '                <label class="layui-form-label">到岗时间</label>\n' +
                '                <div class="layui-input-inline">\n' +
                '                    <input name="date" class="layui-input" id="date'+i+'" type="text" placeholder="请选择时间" autocomplete="off" lay-verify="date">\n' +
                '                </div>\n' +
                '            </div>\n' +
                '        </form>\n'
            $("#chidao"+i+"").html(html);
            laydate.render({
                elem: '#date'+i+'',
                type:'datetime'
            });
        })
        layui.form.on('radio(bbb'+i+')', function(){
            let html =''
            $("#chidao"+i+"").html(html);
        })
    }
});